﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layuimini-v2/lib/layui-v2.6.3/css/layui.css" media="all">

    <link href="~/layuimini-v2/lib/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="/layuimini-v2/css/public.css" media="all">
    <style>
        .layui-top-box {
            padding: 40px 20px 20px 20px;
            color: #fff
        }

        .panel {
            margin-bottom: 17px;
            background-color: #fff;
            border: 1px solid transparent;
            border-radius: 3px;
            -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.05);
            box-shadow: 0 1px 1px rgba(0,0,0,.05)
        }

        .panel-body {
            padding: 15px
        }

        .panel-title {
            margin-top: 0;
            margin-bottom: 0;
            font-size: 14px;
            color: inherit
        }

        .label {
            display: inline;
            padding: .2em .6em .3em;
            font-size: 75%;
            font-weight: 700;
            line-height: 1;
            color: #fff;
            text-align: center;
            white-space: nowrap;
            vertical-align: baseline;
            border-radius: .25em;
            margin-top: .3em;
        }

        .layui-red {
            color: red
        }

        .main_btn > p {
            height: 40px;
        }
    </style>
</head>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">


            <div class="layuimini-main layui-top-box">
                <div class="layui-row layui-col-space10">

                    <div class="layui-col-md3">
                        <div class="col-xs-6 col-md-3">
                            <div class="panel layui-bg-cyan">
                                <div class="panel-body">
                                    <div class="panel-title">
                                        <span class="label pull-right layui-bg-blue">实时</span>
                                        <h5>总报修数</h5>
                                    </div>
                                    <div class="panel-content">
                                        <h1 class="no-margins">@ViewBag.AllCount</h1>
                                        <div class="stat-percent font-bold text-gray"><i class="fa fa-commenting"></i> 1234</div>
                                        <small>当前分类总记录数</small>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-md3">
                        <div class="col-xs-6 col-md-3">
                            <div class="panel layui-bg-blue">
                                <div class="panel-body">
                                    <div class="panel-title">
                                        <span class="label pull-right layui-bg-cyan">实时</span>
                                        <h5>今日报修数</h5>
                                    </div>
                                    <div class="panel-content">
                                        <h1 class="no-margins">@ViewBag.thisCount</h1>
                                        <div class="stat-percent font-bold text-gray"><i class="fa fa-commenting"></i> 1234</div>
                                        <small>当前分类总记录数</small>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-md3">
                        <div class="col-xs-6 col-md-3">
                            <div class="panel layui-bg-green">
                                <div class="panel-body">
                                    <div class="panel-title">
                                        <span class="label pull-right layui-bg-orange">实时</span>
                                        <h5>总维护数</h5>
                                    </div>
                                    <div class="panel-content">
                                        <h1 class="no-margins">@ViewBag.AllSuccess</h1>
                                        <div class="stat-percent font-bold text-gray"><i class="fa fa-commenting"></i> 1234</div>
                                        <small>当前分类总记录数</small>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="col-xs-6 col-md-3">
                            <div class="panel layui-bg-orange">
                                <div class="panel-body">
                                    <div class="panel-title">
                                        <span class="label pull-right layui-bg-green">实时</span>
                                        <h5>今日维修数</h5>
                                    </div>
                                    <div class="panel-content">
                                        <h1 class="no-margins">@ViewBag.thisSuccessCount</h1>
                                        <div class="stat-percent font-bold text-gray"><i class="fa fa-commenting"></i> 1234</div>
                                        <small>当前分类总记录数</small>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


            <fieldset class="table-search-fieldset">
                <legend>搜索信息</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">报修名</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="RepairTitle" autocomplete="off" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label">报修内容</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="RepairContent" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            
                            <div class="layui-inline">
                                <label class="layui-form-label">报修人</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="UserName" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>

            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                    @*<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>*@
                    @*<button class="layui-btn layui-btn-sm " lay-event="open"> 树形结构 </button>*@
                </div>
            </script>

            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

            <script type="text/html" id="currentTableBar">
                <a class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="true">受理</a>
                <a class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="false">拒受</a>
                <a class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="ok">成功</a>
                <a class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="nook">失败</a>
            </script>

        </div>
    </div>
    <script src="/layuimini-v2/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script>
        layui.use(['form', 'table'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table;

            table.render({
                elem: '#currentTableId',
                url: '@Url.Action("GetUserGuaranteeList")',
                toolbar: '#toolbarDemo',
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                cols: [[
                    { type: "checkbox", width: 50 },
                    @*{ field: 'Id', width: 80, title: 'Id', sort: true },*@
                    { field: 'RepairTitle', width: 150, title: '报修名称', sort: true },
                    { field: 'RepairContent', width: 150, title: '报修内容' },
                    { field: 'UserName', width: 150, title: '报修人' },
                    { field: 'EstimatedTime', width: 150, title: '期待上门时间' },
                    { field: 'RepairResult', width: 150, title: '受理情况' },
                    { field: 'CreateTime', title: '创建时间', minWidth: 150 },
                    { field: 'RepairState', width: 80, title: '维修情况' },
                    { title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center" }
                ]],
                limits: [10, 15, 20, 25, 50, 100],
                limit: 5,
                page: true,
                skin: 'line'
            });

            // 监听搜索操作
            form.on('submit(data-search-btn)', function (data) {
                //data.title
                var result = JSON.stringify(data.field);
                @*layer.alert(result, {
                    title: '最终的搜索信息'
                });*@

                //执行搜索重载
                table.reload('currentTableId', {
                    page: {
                        curr: 1
                    }
                    , where: {
                        RepairTitle: data.field.RepairTitle,
                        RepairContent: data.field.RepairContent,
                        UserName: data.field.UserName
                    }
                }, 'data');

                return false;
            });

            /**
             * toolbar监听事件
             */
            table.on('toolbar(currentTableFilter)', function (obj) {
                if (obj.event === 'add') {  // 监听添加操作
                    var index = layer.open({
                        title: '添加菜单',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['60%', '80%'],
                        content: '@Url.Action("AddUserGuarantee")',
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                } else if (obj.event === 'delete') {  // 监听删除操作
                    var checkStatus = table.checkStatus('currentTableId')
                        , data = checkStatus.data;
                    layer.alert(JSON.stringify(data));
                } else if (obj.event === 'open') {
                    var listIndex = layer.open({
                        title: '树形菜单',
                        type: 2,
                        shade: 0.2,
                        maxmin: false,
                        shadeClose: false,
                        area: ['100%', '100%'],
                        content: '@Url.Action("TreeMenusList")'
                    })
                    $(window).on("resize", function () {
                        layer.full(listIndex);
                    });
                }
            });

            //监听表格复选框选择
            table.on('checkbox(currentTableFilter)', function (obj) {
                console.log(obj)
            });

            table.on('tool(currentTableFilter)', function (obj) {
                var data = obj.data;
                if (obj.event === 'true') {
                    layer.confirm('真的受理吗', function (index) {
                        $.ajax({
                            url: "@Url.Action("IsAcceptance")",
                            type: "get",
                            data: { "id": data.Id, "repairResult": true },
                            success: function (da) {
                                console.log(da)
                                layer.msg(da.msg)
                            }
                        })
                        layer.close(index);
                        table.reload('currentTableId', {
                            page: {
                                curr: 1
                            }
                        });
                    });

                } else if (obj.event === 'false') {
                    var index = layer.open({
                        title: '填写原因',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['40%', '30%'],
                        content: '@Url.Action("WriteReason")/' + data.Id,
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                    return false;
                } else if (obj.event === 'ok') {
                    layer.confirm('真的完成吗', function (index) {
                        $.ajax({
                            url: "@Url.Action("SuccessOneData")",
                            type: "get",
                            data: { "id": data.Id, "repairState": true },
                            success: function (da) {
                                console.log(da)
                                layer.msg(da.msg)
                            }
                        })
                        layer.close(index);
                        table.reload('currentTableId', {
                            page: {
                                curr: 1
                            }
                        });
                    });
                }else if (obj.event === 'nook') {
                    var index = layer.open({
                        title: '填写原因',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['40%', '30%'],
                        content: '@Url.Action("WriteReasonToNoOk")/' + data.Id,
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                    return false;
                }
            });

        });
    </script>

</body>
</html>